/**
 * 
 */
package com.jbat.gwt.tiledmapcreator.client.common.color;

/**
 * Defines enums and static factory methods necessary to instantiate a Color object.
 */
public class Colors {
  
  // ensures the class is non-instantiable
  private Colors() {
  }
  
  /**
   * Private enum which enumerates readable names and equates them to rgb value strings.
   */
  static enum RawColors implements Color {
    RED("rgb(255,0,0)"),
    BLACK("rgb(0,0,0)");
    
    private final String rgbString;
    
    private RawColors(String rgbString) {
      this.rgbString = rgbString;
    }

    @Override
    public String getRgbString() {
      return rgbString;
    }
  }
  
  /**
   * Static factory method for the Color type.
   * <p>
   * To use this method, pass in a DefinedColors enum. This method will then return the appropriate
   * Color object that represents the desired color.<br>
   * Example:<br>
   * {@code Color selectedColor = Colors.getInstance(DefinedColors.SELECTED_TILE);}
   * @param color
   * @return a Color object corresponding to the input
   */
  public static Color getInstance(DefinedColors color) {
    switch(color) {
      case SELECTED:
        return RawColors.RED;
      case UNSELECTED:
        return RawColors.BLACK;
      default:
        throw new RuntimeException("DefinedColors enum with value " + color + " is invalid!");
    }
  }
}
